public  class KRotateLeftArray{

	public static void KrotateArray(int input[],int d)
	{
		int n = input.length;
		int start = 0; 
		int end = d-1;
		
		for(int i = 0; i < n; i++)
		System.out.print(input[i]+" ");

		while(start < end)
		{
			int temp = input[start];
			input[start] = input[end];
			input[end] = temp;
			start+=1;
			end-=1;
		}

		start = d;
		end = n-1;
		System.out.println();
		for(int i = 0; i < n; i++)
		System.out.print(input[i]+" ");

		
		while(start < end)
		{
			int temp = input[start];
			input[start] = input[end];
			input[end] = temp;
			start+=1;
			end-=1;

		}

		start = 0; 
		end = n-1;
		System.out.println();
		for(int i = 0; i < n; i++)
		System.out.print(input[i]+" ");

		while(start < end)
		{
			int temp = input[start];
			input[start] = input[end];
			input[end] = temp;
			start+=1;
			end-=1;

		}
		System.out.println();
		for(int i = 0; i < n; i++)
		System.out.print(input[i]+" ");

	}

	public static void main(String[] args) {
		int input[] = {1,2,3,4,5};

		KrotateArray(input,2);
	}
}